package sniff.diller;

import util.ByteUtil;

public class CommonHeadDiller {
	private byte[] head;

	public CommonHeadDiller(byte[] head) {
		this.head = head;
	}
	
	public String getDestinationMAC() {
		String destinationMAC = "";
		for (int i = 0; i < 6; i++) {
			destinationMAC += ByteUtil.byteToHexString(head[i]) + ":";
		}
		destinationMAC = destinationMAC.substring(0, destinationMAC.length() - 1);
		return destinationMAC;
	}
	
	public String getSourceMAC() {
		String sourceMAC = "";
		for (int i = 6; i < 12; i++) {
			sourceMAC += ByteUtil.byteToHexString(head[i]) + ":";
		}
		sourceMAC = sourceMAC.substring(0, sourceMAC.length() - 1);
		return sourceMAC;
	}

	public String getType() {
		String type="";
		int typeCode = ByteUtil.unionByte(head[12], head[13]);
		
		switch(typeCode) {
		case 0x0806:
			type="ARP";
			break;
		case 0x0800:
			type="IPV4";
			break;
		case 0x86dd:
			type ="IPV6";
			break;
		}
		return type;
		
	}
	
	public byte[] getHead() {
		return head;
	}

	public void setHead(byte[] head) {
		this.head = head;
	}
	
	

}
